function add0(m){return m<10?'0'+m:m }

function formatDate(shijianchuo)
{
    //shijianchuo是整数，否则要parseInt转换
    var time = new Date(shijianchuo);
    var y = time.getFullYear();
    var m = time.getMonth()+1;
    var d = time.getDate();
    return y+'-'+add0(m)+'-'+add0(d);
}

function formatTime(shijianchuo)
{
    //shijianchuo是整数，否则要parseInt转换
    var time = new Date(shijianchuo);
    var y = time.getFullYear();
    var m = time.getMonth()+1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
}

function curDay(){
    var date=new Date();
    var year=date.getFullYear();//年
    var month=date.getMonth()+1;//月
    var day=date.getDate();//日
    var rq=year+"-"+month+"-"+day;
    return rq;
}

function curTime(){
    var date=new Date();
    var year=date.getFullYear();//年
    var month=date.getMonth()+1;//月
    var day=date.getDate();//日
    var hh=date.getHours();//时
    var mm=date.getMinutes();//分
    var ss=date.getSeconds();//秒
    var rq=year+"-"+month+"-"+day+" "+hh+":"+mm+":"+ss;
    return rq;
}

//比较时间大小
function compareTime(time1, time2)
{
    if(time1==null&&time2==null){
        return true;
    }
    if(time1==''&&time2==''){
        return true;
    }
    time1=time1.replace(/-/g,"").replace(/ /g,"").replace(/:/g,"");
    time2=time2.replace(/-/g,"").replace(/ /g,"").replace(/:/g,"");

    if(time1<=time2){
        return true;
    }else{
        return false;
    }
}